<?php
/**
 * Role
 *
 * @author      Henrique Moody <henriquemoody@gmail.com>
 */
class App_Acl_Role implements Zend_Acl_Role_Interface
{

    /**
     * Role ID
     *
     * Id of the logged user
     *
     * @var integer
     */
    protected $_roleId;

    /**
     * Constructor
     *
     * @return void
     */
    public function  __construct()
    {
        $auth = Zend_Auth::getInstance();
        if (!$auth->hasIdentity()) {
            $this->_roleId = 0;
            return;
        }
        $this->_roleId = $auth->getIdentity()->getId();
    }

    /**
     * Returns the string identifier of the Role
     *
     * @return string
     */
    public function getRoleId()
    {
        return (string) $this->_roleId;
    }

    /**
     * Returns TRUE if the user id the administrator (userId = 1)
     *
     * @return boolean
     */
    public function isAdmin()
    {
        if ($this->_roleId == 1) {
            return true;
        }
        return false;
    }

    /**
     * Returns TRUE if the user is authenticated
     *
     * But don't includes admin user
     *
     * @return boolean
     */
    public function isAuthenticated()
    {
        if ($this->_roleId > 1) {
            return true;
        }
        return false;
    }

    /**
     * Returns TRUE if the user is a guest
     *
     * @return boolean
     */
    public function isGuest()
    {
        if ($this->_roleId == 0) {
            return true;
        }
        return false;
    }

}
